package com.path.planning.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.locationtech.jts.geom.Geometry;

import java.util.List;

/**
 * 路径规划结果实体
 */
@ApiModel(description = "路径规划结果")
public class RoutingResult {

    @ApiModelProperty(value = "是否成功")
    private Boolean success;

    @ApiModelProperty(value = "错误信息")
    private String errorMessage;

    @ApiModelProperty(value = "总距离（米）")
    private Double totalDistance;

    @ApiModelProperty(value = "总时间（秒）")
    private Double totalTime;

    @ApiModelProperty(value = "路径段数")
    private Integer segmentCount;

    @ApiModelProperty(value = "路径详细信息")
    private List<RoutingSegment> segments;

    @ApiModelProperty(value = "完整路径几何")
    private Geometry fullPath;

    @ApiModelProperty(value = "起点节点ID")
    private Long startNodeId;

    @ApiModelProperty(value = "终点节点ID")
    private Long endNodeId;

    // 构造函数
    public RoutingResult() {}

    public RoutingResult(Boolean success) {
        this.success = success;
    }

    public static RoutingResult success() {
        return new RoutingResult(true);
    }

    public static RoutingResult error(String errorMessage) {
        RoutingResult result = new RoutingResult(false);
        result.setErrorMessage(errorMessage);
        return result;
    }

    // Getter和Setter方法
    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public Double getTotalDistance() {
        return totalDistance;
    }

    public void setTotalDistance(Double totalDistance) {
        this.totalDistance = totalDistance;
    }

    public Double getTotalTime() {
        return totalTime;
    }

    public void setTotalTime(Double totalTime) {
        this.totalTime = totalTime;
    }

    public Integer getSegmentCount() {
        return segmentCount;
    }

    public void setSegmentCount(Integer segmentCount) {
        this.segmentCount = segmentCount;
    }

    public List<RoutingSegment> getSegments() {
        return segments;
    }

    public void setSegments(List<RoutingSegment> segments) {
        this.segments = segments;
    }

    public Geometry getFullPath() {
        return fullPath;
    }

    public void setFullPath(Geometry fullPath) {
        this.fullPath = fullPath;
    }

    public Long getStartNodeId() {
        return startNodeId;
    }

    public void setStartNodeId(Long startNodeId) {
        this.startNodeId = startNodeId;
    }

    public Long getEndNodeId() {
        return endNodeId;
    }

    public void setEndNodeId(Long endNodeId) {
        this.endNodeId = endNodeId;
    }

    @Override
    public String toString() {
        return "RoutingResult{" +
                "success=" + success +
                ", errorMessage='" + errorMessage + '\'' +
                ", totalDistance=" + totalDistance +
                ", totalTime=" + totalTime +
                ", segmentCount=" + segmentCount +
                ", startNodeId=" + startNodeId +
                ", endNodeId=" + endNodeId +
                '}';
    }

    /**
     * 路径段信息
     */
    @ApiModel(description = "路径段信息")
    public static class RoutingSegment {
        
        @ApiModelProperty(value = "段ID")
        private Long id;

        @ApiModelProperty(value = "段名称")
        private String name;

        @ApiModelProperty(value = "段几何")
        private Geometry geom;

        @ApiModelProperty(value = "段长度（米）")
        private Double length;

        @ApiModelProperty(value = "起点ID")
        private Long source;

        @ApiModelProperty(value = "终点ID")
        private Long target;

        @ApiModelProperty(value = "起点坐标")
        private Geometry sourcePoint;

        @ApiModelProperty(value = "终点坐标")
        private Geometry targetPoint;

        // 构造函数
        public RoutingSegment() {}

        // Getter和Setter方法
        public Long getId() {
            return id;
        }

        public void setId(Long id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public Geometry getGeom() {
            return geom;
        }

        public void setGeom(Geometry geom) {
            this.geom = geom;
        }

        public Double getLength() {
            return length;
        }

        public void setLength(Double length) {
            this.length = length;
        }

        public Long getSource() {
            return source;
        }

        public void setSource(Long source) {
            this.source = source;
        }

        public Long getTarget() {
            return target;
        }

        public void setTarget(Long target) {
            this.target = target;
        }

        public Geometry getSourcePoint() {
            return sourcePoint;
        }

        public void setSourcePoint(Geometry sourcePoint) {
            this.sourcePoint = sourcePoint;
        }

        public Geometry getTargetPoint() {
            return targetPoint;
        }

        public void setTargetPoint(Geometry targetPoint) {
            this.targetPoint = targetPoint;
        }

        @Override
        public String toString() {
            return "RoutingSegment{" +
                    "id=" + id +
                    ", name='" + name + '\'' +
                    ", length=" + length +
                    ", source=" + source +
                    ", target=" + target +
                    '}';
        }
    }
}
